-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix size() and namespace lookups so that we can compile with C++17 #2641
Conversation
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
Oh man, Minor Q, but should we just use the entire namespace ( |
@SteveBronder This PR reintroduces the error fixed by #2632 (but at line 41 of diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp
index 5e7a176b8f..7334b8b4f0 100644
--- a/stan/math/prim/fun/scalar_seq_view.hpp
+++ b/stan/math/prim/fun/scalar_seq_view.hpp
@@ -38,7 +38,7 @@ class scalar_seq_view<C, require_eigen_vector_t<C>> {
template <typename T = C, require_st_arithmetic<T>* = nullptr>
inline decltype(auto) val(size_t i) const {
- return c_.coeffRef(i);
+ return c_.coeff(i);
}
template <typename T = C, require_st_autodiff<T>* = nullptr> Here's a complete reproducible example: remove.packages(c("StanHeaders", "rstan"))
remotes::install_github("stan-dev/rstan/StanHeaders@experimental", upgrade = "always", force = TRUE)
remotes::install_github("stan-dev/rstan/rstan/rstan@experimental", upgrade = "always", force = TRUE)
library(rstan)
stancode <- '
data {
real<lower=0> shape;
real<lower=0> rate;
}
parameters {
real<lower=0> alpha[8];
}
model {
target += gamma_lpdf(alpha | shape, rate);
}
'
mod <- stan_model(model_code = stancode, verbose = TRUE) PS: Note that you need to merge this PR into |
@hsbadr Thanks, done! |
@rok-cesnovar very odd, on develop if I add the
I'm getting the same error as jenkins with this PR? It looks like it's something deep in gtest and nothing to do with us?
This seems to happen when I tested it on clang-12 and 10 |
Lol nope nvm I got it sorry |
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Anything else to go into this one? I can review when it's ready |
@serban-nicusor-toptal I'm running into the leak sanitizer CI issues with this PR that haven't been resolved by the switch to Docker and that I can't reproduce locally - even when I run the same commands in the same docker image (
When you've got a minute, would you mind having a look to see if anything obvious stands out or if you're able to reproduce? |
I will run some tests and try to see what's different. |
We probably don't need the test that is causing the sanitizer failures, though it doesn't seem like it should cause issues here. |
The strange thing is that it doesn't fail when I run the tests in the docker image locally, so I'm not sure what's different about the Jenkins setup |
I'll also try splitting this out into smaller PRs to see if I can narrow down the issue, and also make it easier to review and merge |
It might be either a permission issue or a hardware component. |
@SteveBronder now that #2693 has merged the namespace qualifiers, I'm going to close this PR and open a separate PR for just the Let me know if there was anything else in this PR that would be good to add in another PR! |
Summary
This adds
math::
in front of calls to stan math'sapply()
,size()
, andfor_each()
functions so that C++17's std functions are not used during ADL lookup. This should also fix the bug in #2474 so we can update to Eigen 3.4. This also makes all thesize()
functions returnEigen::Index
so that we have a consistent definition of the size we use in stan math. If we don't have a consistent return forsize()
we can end up having compiler errors for functions likestd::max({size_t, int, long int})
since there will be different integer types in the initializer list.NOTE: I'm running this first with C++17 as the default std version in the makefiles just to make sure everything passes. Once we get a green light once I'm going to switch that back to
std=c++1y
Tests
No new tests
Side Effects
One nice thing is that if we ever want to change the default index type we use we can just override
Eigen::Index
to be another integer type.Release notes
Make stan math more easily compilable with C++17
Checklist
Math issue #(issue number)
Copyright holder: Steve Bronder
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested